home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Apple II Magazines (PO)
/
Nibble Volume 10, No. 05 (1989-05)(MicroSPARC)(Side A).zip
/
Nibble Volume 10, No. 05 (1989-05)(MicroSPARC)(Side A).po
/
TOOLBOX.S
< prev
Wrap
Text File
|
1996-12-24
|
6KB
|
173 lines
***********************************
* *
* TOOLBOX DISPATCHER (ROM 01) *
* *
* Interpreted by Sandy Mossberg *
* *
* Merlin-16 Assembler *
* *
***********************************
SysTPTPtr = $E103C0 ;ptr to System Tool Pointer Table
UserTPTPtr = $E103C4 ;ptr to User Tool Pointer Table
SysWAPTPtr = $E103C8 ;ptr to System Work Area Ptr Table
UserWAPTPtr = $E103CC ;ptr to User Work Area Ptr Table
*-------------------------------
* Toolbox Dispatcher Vectors:
*-------------------------------
ORG $E10000
DISPATCH1 JML SysTLEntry1 ;JSL directly to system dispatcher
DISPATCH2 JML SysTLEntry2 ;JSL to JSL to system dispatcher
UDISPATCH1 JML UserTLEntry1 ;JSL directly to user dispatcher
UDISPATCH2 JML UserTLEntry2 ;JSL to JSL to user dispatcher
*-------------------------------
* Toolbox Dispatcher Code:
*-------------------------------
ORG $FE0069
* USER DISPATCHER:
*--> Type 2 User Dispatcher (JSL to JSL UDISPATCH2 comes here):
UserTLEntry2 REP %00110000 ;set full 16-bit mode
TSC ;get entry SP
SEC
SBC #$0007 ;subtract 7 from SP
TCS ;reset SP
PHD ;save entry DP on stack
TCD ;equate DP to current SP
BRA UserTLEntry
*--> Type 1 User Dispatcher (JSL UDISPATCH1 comes here):
UserTLEntry1 REP %00110000 ;set full 16-bit mode
TSC ;get entry SP
SEC
SBC #$000A ;subtract 10 from SP
TCS ;reset SP
PHD ;save entry DP on stack
TCD ;equate DP to current SP
LDA #TLRTL-1 ;place 3-byte address
STA $08 ; of RTL-1 instruction
LDA #>TLRTL-1 ; on stack/in DP
STA $09 ; ($08-$0A)
*--> Common User Dispatcher:
UserTLEntry LDAL UserTPTPtr ;place 3-byte address
STA $05 ; of user TPT
LDAL UserTPTPtr+1 ; on stack/in DP
STA $06 ; ($05-$07)
LDAL UserWAPTPtr ;place 4-byte address
STA $01 ; of user WAPT
LDAL UserWAPTPtr+2 ; on stack/in DP
STA $03 ; ($01-$04)
BRA TLEntry
* SYSTEM DISPATCHER:
*--> Type 2 System Dispatcher (JSL to JSL DISPATCH2 comes here):
SysTLEntry2 REP %00110000 ;set full 16-bit mode
TSC ;get entry SP
SEC
SBC #$0007 ;subtract 7 from SP
TCS ;reset SP
PHD ;save entry DP on stack
TCD ;equate DP to current SP
BRA SysTLEntry
*--> Type 1 System Dispatcher (JSL DISPATCH1 comes here):
SysTLEntry1 REP %00110000 ;set full 16-bit mode
TSC ;get entry SP
SEC
SBC #$000A ;subtract 10 from SP
TCS ;reset SP
PHD ;save entry DP on stack
TCD ;equate DP to current SP
LDA #TLRTL-1 ;place 3-byte address
STA $08 ; of RTL-1 instruction
LDA #>TLRTL-1 ; on stack/in DP
STA $09 ; ($08-$0A)
*--> Common System Dispatcher:
SysTLEntry LDAL SysTPTPtr ;place 3-byte address
STA $05 ; of system TPT
LDAL SysTPTPtr+1 ; on stack/in DP
STA $06 ; ($05-$07)
LDAL SysWAPTPtr ;place 4-byte address
STA $01 ; of system WAPT
LDAL SysWAPTPtr+2 ; on stack/in DP
STA $03 ; ($01-$04)
* COMMON DISPATCHER:
TLEntry TXA ;entry X-reg = function #/tool set #
PHA ;save entry X-reg on stack
AND #$00FF ;isolate tool set byte
BEQ ToolSetErr ;error (tool set number too small)
CMP [$05] ;check number of tool sets in TPT
BCS ToolSetErr ;error (tool set number too large)
ASL ;quadruple tool set number to index
ASL ; TPT and WAPT 4-byte entries
TAY ;Y-reg indexes table entry
LDA [$01],Y ;get lo order bytes in WAPT (ML,LL)
TAX ; and save in X-reg
INY ;point at hi order
INY ; bytes in WAPT
LDA [$01],Y ;get hi order bytes in WAPT (HH,MH)
STA $03 ;reset $01-$04 to point
STX $01 ; at work area
DEY ;point at mid order bytes in TPT
LDA [$05],Y ;get mid order bytes in TPT (MH,ML)
TAX ; and save in X-reg
DEY ;point at lo order bytes in TPT
LDA [$05],Y ;get lo order bytes in TPT (ML,LL)
STA $05 ;reset $05-$07 to
STX $06 ; point at FPT
LDA $02,S ;isolate function
AND #$00FF ; number byte
BEQ ToolFunctErr ;error (function number too small)
CMP [$05] ;check number of functions in FPT
BCS ToolFunctErr ;error (function number too large)
ASL ;quadruple function number to
ASL ; index FPT 4-byte entries
TAY ;Y-reg indexes FPT entry
LDA [$05],Y ;get lo order bytes in
TAX ; FPT (ML,LL) into X-reg
INY ;point at and get mid order
LDA [$05],Y ; bytes in FPT (MH,ML)
STA $06 ;reset $05-$07 to point
STX $05 ; at function handler-1
* NORMAL RETURN FROM DISPATCHER:
PLX ;X-reg = function #/tool set #
PLD ;restore entry direct page
PLA ;A-reg = lo order WAPT address
PLY ;Y-reg = hi order WAPT address
RTL ;funny jump to function handler
* ERROR RETURN FROM DISPATCHER:
ToolSetErr LDX #$0001 ;signal toolNotFoundErr
BRA ToolErr
ToolFunctErr LDX #$0002 ;signal funcNotFoundErr
ToolErr PLA ;discard entry X-reg
PLD ;restore entry direct page
TSC ;return SP
CLC ; to entry
ADC #$000A ; value by
TCS ; adding 10
TXA ;A-reg = error code
SEC ;signal error
TLRTL RTL ;return to caller
LST OFF